package design_patterns

// 工厂模式
type product interface {
	showMessage() string
}

type concreteProductA struct{}

func (p *concreteProductA) showMessage() string {
	return "I am Product A"
}

type concreteProductB struct{}

func (p *concreteProductB) showMessage() string {
	return "I am Product B"
}

type factory struct{}

func (f *factory) createProduct(productType int) product {
	switch productType {
	case 1:
		return &concreteProductA{}
	case 2:
		return &concreteProductB{}
	default:
		return nil
	}
}
